import tkinter as tk
import random

class GuessingGame:
    def  __init__(self, master):
        self.master = master
        self.master.title("Угадай число")
        self.master.configure(bg='#E6F2FA')
        
        self.secret_number = random.randint(1, 128)
        
        self.label = tk.Label(master, text="Введите число от 1 до 128:", bg='#E6E6FA', fg='#4B0082')
        self.label.pack()
        
        self.entry = tk.Entry(master, bg='#FFFACD', fg='#000000')
        self.entry.pack()
        
        self.check_button = tk.Button(master, text="Проверить", command=self.check_guess, bg='#9370DB', fg='#FFFFFF')
        self.check_button.pack()
        
        self.result_text = tk.Text(master, height=5, width=30, bg='#FFAACD', fg='#000000')
        self.result_text.pack()
        
    def check_guess(self):
        guess = int(self.entry.get())
        if guess < self.secret_number:
            self.result_text.insert(tk.END, "Загаданное число больше\n")
        elif guess > self.secret_number:
            self.result_text.insert(tk.END, "Загаданное число меньше\n")
        else:
            self.result_text.insert(tk.END, "Вы угадали!\n")
            self.result_text.insert(tk.END, f"Загаданное число было {self.secret_number}\n")
            self.entry.config(state=tk.DISABLED)
            self.check_button.config(state=tk.DISABLED)

def main():
    root = tk.Tk()
    app = GuessingGame(root)
    root.mainloop()

if __name__ == "__main__":
    main()

